<template>
  <el-container class="ele-body">
    <el-header class="m-header ele-bg-white">
      <!-- 搜索表单 -->
      <el-form
        :model="where"
        label-width="77px"
        class="ele-form-search"
        @keyup.enter.native="reload"
        @submit.native.prevent>
        <el-row>
          <el-col :md="4" :sm="12">
            <el-form-item label="起始日期:">
              <el-date-picker size="mini" v-model="where.riqiBegin" type="date" format='yyyy-MM-dd' value-format='yyyy-MM-dd' placeholder="选择日期" clearable class="ele-fluid"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :md="4" :sm="12">
            <el-form-item label="结束日期:">
              <el-date-picker size="mini" v-model="where.riqiEnd" type="date" format='yyyy-MM-dd' value-format='yyyy-MM-dd' placeholder="选择日期" clearable class="ele-fluid"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :lg="4" :md="12">
            <el-form-item label="单据号:">
              <el-input size="mini"
                        clearable
                        v-model="where.vbillcode"
                        placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :lg="4" :md="12">
            <el-form-item label="板块:" label-width="50px">
              <el-select size="mini"
                         clearable
                         v-model="where.orgcode"
                         placeholder="请选择板块"
                         class="ele-fluid">
                <el-option v-for="item in ssbkList" :label="item.name" :value="item.code" :key="item.code" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :lg="3" :md="12">
            <el-form-item label="箱型:" label-width="50px">
              <el-select size="mini"
                         clearable
                         v-model="where.boxflag"
                         placeholder="请选择"
                         class="ele-fluid">
                <el-option label="整箱" value="ZX"></el-option>
                <el-option label="拼箱" value="PX"></el-option>
                <el-option label="零箱" value="LX"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :lg="4" :md="12">
            <el-form-item label="箱号:" label-width="50px">
              <el-input size="mini"
                        clearable
                        v-model="where.boxno"
                        placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :lg="4" :md="12">
            <el-form-item label="入库类型:">
              <el-select size="mini"
                         clearable
                         v-model="where.billtypename"
                         placeholder=""
                         class="ele-fluid">
                <el-option v-for="item in billTypeList" :label="item" :value="item" :key="item" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :lg="4" :md="12">
            <el-form-item label="药品:">
              <el-input size="mini"
                        clearable
                        v-model="where.materialcode"
                        placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :lg="4" :md="12">
            <el-form-item label="批号:">
              <el-input size="mini"
                        clearable
                        v-model="where.vendorbatch"
                        placeholder=""/>
            </el-form-item>
          </el-col>
          <!--          <el-col :lg="4" :md="12">-->
          <!--            <el-form-item label="转出库位:">-->
          <!--              <el-input size="mini"-->
          <!--                        clearable-->
          <!--                        v-model="where.fromlocation"-->
          <!--                        placeholder=""/>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <!--          <el-col :lg="4" :md="12">-->
          <!--            <el-form-item label="转入库位:" label-width="80px">-->
          <!--              <el-input size="mini"-->
          <!--                        clearable-->
          <!--                        v-model="where.tolocation"-->
          <!--                        placeholder=""/>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <!--          <el-col :lg="4" :md="12">-->
          <!--            <el-form-item label="状态:" label-width="50px">-->
          <!--              <el-select size="mini"-->
          <!--                         clearable-->
          <!--                         v-model="where.status"-->
          <!--                         placeholder="请选择操作状态"-->
          <!--                         class="ele-fluid">-->
          <!--                <el-option label="已回写" value="已回写"></el-option>-->
          <!--                <el-option label="未回写" value="未回写"></el-option>-->
          <!--              </el-select>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <el-col :lg="4" :md="12">
            <div class="ele-form-actions">
              <el-button
                type="primary"
                icon="el-icon-search"
                class="ele-btn-icon"
                size="mini"
                @click="reload">查询
              </el-button>
              <el-button @click="reset" size="mini" class="ele-btn-icon">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-header>
    <el-main>
      <!-- 数据表格 -->
      <ele-pro-table
        ref="table"
        :where="where"
        :datasource="url"
        :columns="columns"
        :selection.sync="selection"
        :toolbar="false"
        :header-cell-style="{'text-align':'center'}"
        highlight-current-row
        @row-click="loadDetail"
        height="calc((100vh - 180px)/2)">
        <!-- 表头工具栏 -->
        <template slot="toolbar" >
          <el-button v-if="false"
                     size="small"
                     type="primary"
                     icon="el-icon-plus"
                     class="ele-btn-icon"
                     @click="openEdit(null)"
          >NC回写
          </el-button>
          <el-button
            size="small"
            type="danger"
            icon="el-icon-delete"
            class="ele-btn-icon"
            @click="removeBatch"
            v-if="false"
          >删除
          </el-button>
        </template>
        <!-- 操作列 -->
        <template slot="action" slot-scope="{row}">
          <el-link v-if="false"
                   type="primary"
                   :underline="false"
                   icon="el-icon-upload2"
                   @click="openEdit(row)"
          >NC回写
          </el-link>
          <el-link v-if="false"
                   type="success"
                   slot="reference"
                   :underline="false"
                   icon="el-icon-document"
                   @click="openLog(row)"
          >日志
          </el-link>
          <el-link
            type="primary"
            :underline="false"
            icon="el-icon-search"
            @click="openDetail(row)"
          >单据明细
          </el-link>

        </template>
      </ele-pro-table>
    </el-main>
    <el-footer class="m-footer">
      <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
        <el-tab-pane label="出库明细" name="first">
          <ele-pro-table
            ref="tableMaterial"
            :where="where"
            :datasource="orderDetail"
            :columns="columnsMaterial"
            :need-page="false"
            :toolbar="false"
            height="calc((100vh - 350px)/2)">
            <!-- 表头工具栏 -->
            <template slot="toolbar" v-if="false">
              <el-button
                size="small"
                type="primary"
                icon="el-icon-plus"
                class="ele-btn-icon"
                @click="openEdit(null)"
                v-if="permission.includes('sys:c37infckscbillnew:add')">添加
              </el-button>
              <el-button
                size="small"
                type="danger"
                icon="el-icon-delete"
                class="ele-btn-icon"
                @click="removeBatch"
                v-if="permission.includes('sys:c37infckscbillnew:dall')">删除
              </el-button>
            </template>
            <!-- 操作列 -->
            <!-- 操作列 -->
            <template slot="action" slot-scope="{row}">
              <el-link
                type="primary"
                :underline="false"
                icon="el-icon-upload2"
                @click="openEdit(row)"
              >NC回写
              </el-link>
              <el-link
                type="success"
                slot="reference"
                :underline="false"
                icon="el-icon-document"
                @click="openLog(row)"
              >日志
              </el-link>
              <el-link v-if="false"
                       type="primary"
                       :underline="false"
                       icon="el-icon-search"
                       @click="openDetail(row)"
              >单据明细
              </el-link>

            </template>
          </ele-pro-table>

        </el-tab-pane>
        <el-tab-pane label="出库" name="second" v-if="false">
          <ele-pro-table
            ref="tableSO"
            :where="where"
            :datasource="orderInvoice"
            :columns="columnsSO"
            :need-page="false"
            :toolbar="false"
            height="calc((100vh - 350px)/2)">
            <!-- 表头工具栏 -->
            <template slot="toolbar" v-if="false">
              <el-button
                size="small"
                type="primary"
                icon="el-icon-plus"
                class="ele-btn-icon"
                @click="openEdit(null)"
                v-if="permission.includes('sys:c37infckscbillnew:add')">添加
              </el-button>
              <el-button
                size="small"
                type="danger"
                icon="el-icon-delete"
                class="ele-btn-icon"
                @click="removeBatch"
                v-if="permission.includes('sys:c37infckscbillnew:dall')">删除
              </el-button>
            </template>
            <!-- 操作列 -->
            <!-- 操作列 -->
            <template slot="action" slot-scope="{row}">
              <el-link
                type="primary"
                :underline="false"
                icon="el-icon-upload2"
                @click="openEdit(row)"
              >NC回写
              </el-link>
              <el-link
                type="success"
                slot="reference"
                :underline="false"
                icon="el-icon-document"
                @click="openLog(row)"
              >日志
              </el-link>
              <el-link v-if="false"
                       type="primary"
                       :underline="false"
                       icon="el-icon-search"
                       @click="openDetail(row)"
              >单据明细
              </el-link>

            </template>
          </ele-pro-table>
        </el-tab-pane>
        <el-tab-pane label="验收" v-if="false" name="third">
          <ele-pro-table
            ref="tableRK"
            :where="where"
            :datasource="orderReturnInvoice"
            :columns="columnsRK"
            :need-page="false"
            :toolbar="false"
            height="calc((100vh - 350px)/2)">
            <!-- 表头工具栏 -->
            <template slot="toolbar" v-if="false">
              <el-button
                size="small"
                type="primary"
                icon="el-icon-plus"
                class="ele-btn-icon"
                @click="openEdit(null)"
                v-if="permission.includes('sys:c37infckscbillnew:add')">添加
              </el-button>
              <el-button
                size="small"
                type="danger"
                icon="el-icon-delete"
                class="ele-btn-icon"
                @click="removeBatch"
                v-if="permission.includes('sys:c37infckscbillnew:dall')">删除
              </el-button>
            </template>
            <!-- 操作列 -->
            <!-- 操作列 -->
            <template slot="action" slot-scope="{row}">
              <el-link
                type="primary"
                :underline="false"
                icon="el-icon-upload2"
                @click="openEdit(row)"
              >NC回写
              </el-link>
              <el-link
                type="success"
                slot="reference"
                :underline="false"
                icon="el-icon-document"
                @click="openLog(row)"
              >日志
              </el-link>
              <el-link v-if="false"
                       type="primary"
                       :underline="false"
                       icon="el-icon-search"
                       @click="openDetail(row)"
              >单据明细
              </el-link>

            </template>
          </ele-pro-table>
        </el-tab-pane>
        <el-tab-pane label="退货发票信息" name="fourth" v-if="false">
          <ele-pro-table
            ref="tableFP"
            :where="where"
            :datasource="orderReturnInvoice"
            :columns="columnsFP"
            :need-page="false"
            :toolbar="false"
            height="calc((100vh - 250px)/2)">
            <!-- 表头工具栏 -->
            <template slot="toolbar" v-if="false">
              <el-button
                size="small"
                type="primary"
                icon="el-icon-plus"
                class="ele-btn-icon"
                @click="openEdit(null)"
                v-if="permission.includes('sys:c37infckscbillnew:add')">添加
              </el-button>
              <el-button
                size="small"
                type="danger"
                icon="el-icon-delete"
                class="ele-btn-icon"
                @click="removeBatch"
                v-if="permission.includes('sys:c37infckscbillnew:dall')">删除
              </el-button>
            </template>
            <!-- 操作列 -->
            <!-- 操作列 -->
            <template slot="action" slot-scope="{row}">
              <el-link
                type="primary"
                :underline="false"
                icon="el-icon-upload2"
                @click="openEdit(row)"
              >NC回写
              </el-link>
              <el-link
                type="success"
                slot="reference"
                :underline="false"
                icon="el-icon-document"
                @click="openLog(row)"
              >日志
              </el-link>
              <el-link v-if="false"
                       type="primary"
                       :underline="false"
                       icon="el-icon-search"
                       @click="openDetail(row)"
              >单据明细
              </el-link>

            </template>
          </ele-pro-table>
        </el-tab-pane>
      </el-tabs>
    </el-footer>
    <LogList
      :dataItem="current"
      :visible.sync="showLog"
    />
    <!--    <BillDetail-->
    <!--      :dataItem="current"-->
    <!--      :visible.sync="showDetail"-->
    <!--    />-->

  </el-container>
</template>

<script>
import { mapGetters } from "vuex";
import LogList from '../../masterdata/loglist.vue';
import setting from "@/config/setting";
export default {
  name: 'ExamNCGeneralOut',
  components: {LogList},
  computed: {
    ...mapGetters(["permission"]),
  },
  data() {
    return {
      // 表格数据接口
      url: '/kdl/ncgeneralin',
      // 表格列配置
      columns: [
        {
          columnKey: 'index',
          type: 'index',
          width: 45,
          align: 'center',
        },
        {
          prop: 'orgname',
          label: '库存组织',
          showOverflowTooltip: true,
          minWidth: 150,
          align: 'left'
        },

        {
          prop: 'vbillcode',
          label: '单据号',
          showOverflowTooltip: true,
          minWidth: 150,
          align: 'center'
        },
        {
          prop: 'dbilldate',
          label: '单据日期',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'storename',
          label: '仓库',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'billtypename',
          label: '入库类型',
          showOverflowTooltip: true,
          minWidth: 150,
          align: 'center'
        },
        // {
        //   prop: 'psnname',
        //   label: '业务员',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },
        // {
        //   prop: 'deptname',
        //   label: '部门',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },
        // {
        //   prop: 'ntotalnum',
        //   label: '总数量',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },
        {
          prop: 'createor',
          label: '制单人',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'createtime',
          label: '制单日期',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        {
          prop: 'appuser',
          label: '签字人',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'apprtime',
          label: '签字日期',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        {
          prop: 'vmemo',
          label: '备注',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'cgeneralhid',
          label: '订单主键',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'left'
        },
        {
          prop: 'orgcode',
          label: '组织代码',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'ts',
          label: 'TS',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        // {
        //   prop: 'shouhStaff',
        //   label: '收货员',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'hanghao',
        //   label: '行号',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'shangpNo',
        //   label: '商品编号',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'lot',
        //   label: '批号',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'shengcChar',
        //   label: '生产日期',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'youxChar',
        //   label: '有效期',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'rukType',
        //   label: '入库类型',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'jihNum',
        //   label: '计划数量',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'num',
        //   label: '实际数量',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'price',
        //   label: '价格',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'hanghCgd',
        //   label: '采购单行号',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'zhijStaff',
        //   label: '质检员',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'pingxNo',
        //   label: '拼箱号',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'yansRlt',
        //   label: '验收评定',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'khZzbm',
        //   label: 'NC组织编码',
        //   showOverflowTooltip: true,
        //   minWidth: 100,
        //   align: 'center'
        // },
        // {
        //   prop: 'yezId',
        //   label: '九州通业主编码',
        //   showOverflowTooltip: true,
        //   minWidth: 140,
        //   align: 'center'
        // },
        // {
        //   columnKey: 'action',
        //   label: '操作',
        //   width: 100,
        //   align: 'center',
        //   resizable: false,
        //   slot: 'action',
        //   fixed: "right"
        // }

      ],
      columnsMaterial:[
        {
          columnKey: 'index',
          type: 'index',
          width: 45,
          align: 'center',
        },
        {
          prop: 'materialcode',
          label: '药品编码',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'comdescription',
          label: '通用名',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'left'
        },
        {
          prop: 'materialspec',
          label: '规格',
          showOverflowTooltip: true,
          minWidth: 150,
          align: 'left'
        },
        {
          prop: 'materialunit',
          label: '单位',
          showOverflowTooltip: true,
          minWidth: 50,
          align: 'center'
        },
        {
          prop: 'nassistnum',
          label: '数量',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'ncostprice',
          label: '单价',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'ncostmny',
          label: '金额',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'vendorbatch',
          label: '批号',
          showOverflowTooltip: true,
          minWidth: 130,
          align: 'center'
        },
        {
          prop: 'manufacturedate',
          label: '生产日期',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'expireddate',
          label: '有效期',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'umrez',
          label: '箱规',
          showOverflowTooltip: true,
          minWidth: 60,
          align: 'center'
        },
        {
          prop: 'boxflag',
          label: '箱型',
          showOverflowTooltip: true,
          minWidth: 70,
          align: 'center'
        },
        {
          prop: 'boxno',
          label: '箱号',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'materialtype',
          label: '药品分类',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        {
          prop: 'manufacturername',
          label: '生产企业',
          showOverflowTooltip: true,
          minWidth: 180,
          align: 'left'
        },
        {
          prop: 'lregistno',
          label: '批准文号',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        {
          prop: 'registrationfilingapplicantname',
          label: '上市许可持有人',
          showOverflowTooltip: true,
          minWidth: 180,
          align: 'center'
        },
        // {
        //   prop: 'remark',
        //   label: '备注',
        //   showOverflowTooltip: true,
        //   minWidth: 140,
        //   align: 'center',
        //   // slot: 'remark'
        // },
        // {
        //   prop: 'opertype',
        //   label: '后续处理',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center',
        //   // slot: 'remark'
        // },
        // {
        //   prop: 'csaleorderid',
        //   label: '主表主键',
        //   showOverflowTooltip: true,
        //   minWidth: 165,
        //   align: 'center'
        // },
        // {
        //   prop: 'csaleorderbid',
        //   label: '子表主键',
        //   showOverflowTooltip: true,
        //   minWidth: 165,
        //   align: 'center'
        // },

      ],
      columnsSO:[
        {
          columnKey: 'index',
          type: 'index',
          width: 45,
          align: 'center',
        },
        {
          prop: 'ybillcode',
          label: '原订单号',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        // {
        //   prop: 'orderdate',
        //   label: '原订单日期',
        //   showOverflowTooltip: true,
        //   minWidth: 140,
        //   align: 'center'
        // },
        {
          prop: 'vsrccode',
          label: '原出库单号',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        // {
        //   prop: 'nnum',
        //   label: '原出库日期',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },
        {
          prop: 'vgoldtaxcode',
          label: '原发票号',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'dbilldate',
          label: '原发票日期',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'invoicenum',
          label: '发票数量',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'nqtorigtaxprice',
          label: '发票含税单价',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'nqtorigprice',
          label: '发票无税单价',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'norigtaxmny',
          label: '发票价税合计',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        {
          prop: 'norigmny',
          label: '无税合计',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        {
          prop: '',
          label: '原件数',
          showOverflowTooltip: true,
          minWidth: 165,
          align: 'center'
        },

      ],
      columnsRK:[
        {
          columnKey: 'index',
          type: 'index',
          width: 45,
          align: 'center',
        },
        {
          prop: 'ssbk',
          label: '所属板块',
          showOverflowTooltip: true,
          minWidth: 180,
          align: 'center'
        },
        {
          prop: 'checkdate',
          label: '退货入库时间',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'invcode',
          label: '药品编码',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'invname',
          label: '药品名称',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'left'
        },
        {
          prop: 'vlotno',
          label: '批号',
          showOverflowTooltip: true,
          minWidth: 130,
          align: 'center'
        },
        {
          prop: 'storename',
          label: '仓库',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'hgsl',
          label: '验收合格数量',
          showOverflowTooltip: true,
          minWidth: 140,
          maxWidth: 150,
          align: 'center'
        },
        {
          prop: 'bhgsl',
          label: '验收不合格数量',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        {
          prop: 'vdef7',
          label: '红票通知单',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'vgoldtaxcode',
          label: '红票金税号',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        {
          prop: 'dbilldate',
          label: '红票日期',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        // {
        //   prop: 'nnum',
        //   label: '蓝票金税号',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },
        // {
        //   prop: 'nprice',
        //   label: '蓝票日期',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },
        {
          prop: 'nqtorigtaxprice',
          label: '含税单价',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'nqtorigprice',
          label: '无税单价',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'nastnum',
          label: '数量',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'norigmny',
          label: '无税金额',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        // {
        //   prop: 'nnum',
        //   label: '退货入库时间',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },
        // {
        //   prop: 'rksl',
        //   label: '入库数量（合格+不合格）',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },
        // {
        //   prop: 'ntaxprice',
        //   label: '实际入库件数',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },

      ],
      columnsFP:[
        {
          columnKey: 'index',
          type: 'index',
          width: 45,
          align: 'center',
        },
        {
          prop: 'vdef7',
          label: '红票通知单',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'vgoldtaxcode',
          label: '红票金税号',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        {
          prop: 'vlotno',
          label: '批号',
          showOverflowTooltip: true,
          minWidth: 130,
          align: 'center'
        },
        {
          prop: 'dbilldate',
          label: '红票日期',
          showOverflowTooltip: true,
          minWidth: 140,
          align: 'center'
        },
        // {
        //   prop: 'nnum',
        //   label: '蓝票金税号',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },
        // {
        //   prop: 'nprice',
        //   label: '蓝票日期',
        //   showOverflowTooltip: true,
        //   minWidth: 80,
        //   align: 'center'
        // },
        {
          prop: 'nqtorigtaxprice',
          label: '含税单价',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'nqtorigprice',
          label: '无税单价',
          showOverflowTooltip: true,
          minWidth: 80,
          align: 'center'
        },
        {
          prop: 'nastnum',
          label: '数量',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
        {
          prop: 'norigmny',
          label: '无税金额',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center'
        },
      ],
      // 表格搜索条件
      where: {riqiBegin:this.getFromDate(),riqiEnd:new Date(),breturn:'N',billtype:'N004'},
      // 表格选中数据
      selection: [],
      orderDetail:[],
      ssbkList:[],
      billTypeList:[],
      // 当前编辑数据
      current: null,
      // 是否显示编辑弹窗
      showEdit: false,
      showLog: false,
      showDetail:false,
      activeName: 'first',
    };
  },
  mounted() {
    // if(setting.takeItem("so_billtype")!='')
    // {
    //   this.where.billtype = setting.takeItem("so_billtype");
    //   this.reload();
    // }
    this.getSsbkList();
    this.getBillTypeList();
  },
  watch:{
    $route(to){
      this.where.billtype =to.meta.menuCode;
      if(this.where.billtype!=''){
        setting.cacheItem("so_billtype",this.where.billtype);
      }
      else{
        this.where.billtype = setting.takeItem("so_billtype");
      }
      console.log(this.to);
      this.reload();
    }
  },
  methods: {
    /* 获取所属版块 */
    async getSsbkList(){
      var res = await this.$http.get('/dictdata/index?dictId=19&page=1&limit=1000');
      if(res.status==200)
      {
        this.ssbkList = res.data.data.records;
      }

    },
    async getBillTypeList(){
      var res = await this.$http.get('/kdl/ncinbilltype');
      if(res.status==200)
      {
        this.billTypeList = res.data.data;
      }

    },
    getFromDate() {
      const timeOne = new Date()
      const year = timeOne.getFullYear()
      let month = timeOne.getMonth()
      let day = 1
      //month = month < 10 ? '0' + month : month
      //day = day < 10 ? '0' + day : day
      ///const NOW_MONTHS_AGO = `${year}-${month}-${day}`
      return new Date(year,month,day);
    },
    async loadDetail(row)
    {
      var res = await this.$http.get('/kdl/ncgeneralindetail?cgeneralhid='+row.cgeneralhid);
      if(Number(res.status)==200)
      {
        this.orderDetail = res.data.data;
      }
    },

    /* 刷新表格 */
    reload() {
      this.orderDetail = [];
      this.$refs.table.reload({where: this.where});
    },
    /* 重置搜索 */
    reset() {
      this.where = {riqiBegin:this.getFromDate(),riqiEnd:new Date(),breturn:'N'};
      this.reload();
    },

    openLog(row){
      console.log(row);
      this.current = row;
      this.showLog = true;
    },

    openDetail(row){
      console.log(row);
      this.current = row;
      this.showDetail = true;
    },
    /* 显示编辑 */
    openEdit(row) {
      // if (!this.selection.length) {
      //   this.$message.error('请至少选择一条数据');
      //   return;
      // }
      this.$confirm('确定要将选中的采购入库记录回写至NC吗?', '提示', {
        type: 'warning'
      }).then(() => {
        const loading = this.$loading({lock: true});
        this.$http.post('/esbservice/cgrk/'+ [row.rukNo]).then(res => {
          loading.close();
          if (res.data.code === 0) {
            this.$message.success(res.data.msg);
            //this.reload();
          } else {
            this.$message.error(res.data.msg);
          }
        }).catch(e => {
          loading.close();
          this.$message.error(e.message);
        });
      }).catch(() => {
      });
    },
    /* 删除 */
    remove(row) {
      const loading = this.$loading({lock: true});
      this.$http.delete('/c37infrkscbillnew/delete', {id: row.id}).then(res => {
        loading.close();
        if (res.data.code === 0) {
          this.$message.success(res.data.msg);
          this.reload();
        } else {
          this.$message.error(res.data.msg);
        }
      }).catch(e => {
        loading.close();
        this.$message.error(e.message);
      });
    },
    /* 批量删除 */
    removeBatch() {
      if (!this.selection.length) {
        this.$message.error('请至少选择一条数据');
        return;
      }
      this.$confirm('确定要删除选中的采购入库/销售退回上传单表吗?', '提示', {
        type: 'warning'
      }).then(() => {
        const loading = this.$loading({lock: true});
        this.$http.delete('/c37infrkscbillnew/delete', {id: this.selection.map(d => d.id)}).then(res => {
          loading.close();
          if (res.data.code === 0) {
            this.$message.success(res.data.msg);
            this.reload();
          } else {
            this.$message.error(res.data.msg);
          }
        }).catch(e => {
          loading.close();
          this.$message.error(e.message);
        });
      }).catch(() => {
      });
    },
  }
}
</script>

<style scoped>
.m-header {
  height: 75px !important;
}
.m-footer {
  height: calc((100vh - 270px)/2) !important;
}
.el-form-item{
  margin-bottom: 0px;
}
</style>
